package client;

import java.awt.*;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.*;
import client.controlleur.*;
import client.gui.*;

@SuppressWarnings("serial")
public class Fenetre extends JFrame implements infos, WindowListener {
	private Controlleur controlleur;

	private IAffichageClient gui;

	public Fenetre() {
		setSize(new Dimension(LARGEUR, HAUTEUR));
		setLocationRelativeTo(null);
		setResizable(false);
		setLayout(null);
		setTitle(TITRE);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setLayout(new BorderLayout());

		gui = new AffichageJoueur(this);
		add(gui, BorderLayout.CENTER);
		controlleur = new Controlleur(gui);
		gui.setControlleur(controlleur);
		gui.choixAffichage(AffichageJoueur.ENTRER_INFOS_SERVEUR);
		setVisible(true);
		this.addWindowListener(this);
	}

	@Override
	protected void finalize() throws Throwable {
		System.out.println("finalize");
		super.finalize();
	}

	@Override
	public void windowActivated(WindowEvent e) {
	}

	@Override
	public void windowClosed(WindowEvent e) {
	}

	@Override
	public void windowClosing(WindowEvent e) {
		System.out.println("window closing");
		controlleur.finConnection();
	}

	@Override
	public void windowDeactivated(WindowEvent e) {
	}

	@Override
	public void windowDeiconified(WindowEvent e) {
	}

	@Override
	public void windowIconified(WindowEvent e) {
	}

	@Override
	public void windowOpened(WindowEvent e) {
	}
}
